//Chuong trinh tinh gia tri bieu thuc bang cach cai dat stack
//Ho va ten: Phan Van Tung
//MSSV: 09520394

#include <conio.h>
#include <string.h>
using namespace std;

//Khai bao kieu du lieu node
struct node
{
	char info;
	node *pnext;
};

//Khai bao kieu du lieu stack
struct stack
{
	node *phead;
	node *ptail;
};

//Dinh nghia ham tao 1 node tu 1 ki tu
node* createnode(char x)
{
	node *p=new node;
	if(p==NULL) return NULL;
	p->info=x;
	p->pnext=NULL;
	return p;
}

//Dinh nghia ham khoi tao stack
void createstack(stack &s)
{
	s.phead=NULL;
	s.ptail=NULL;
}

//Dinh nghia ham them phan tu moi vao dau stack
void push(stack &s,node *p)
{
	if(s.shead==NULL)
	{
		s.phead==p;
		s.stail=p;
	}
	else
	{
		p->pnext=s.phead;
		s.phead=p;
	}
}

//Dinh nghia ham xoa phan tu dau khoi stack
void pop(stack &s)
{
	p=s.phead;
	if(p!=NULL)
	{
		s.phead=s.phead->pnext;
		if(s.phead==NULL)
			s.ptail=NULL;
		delete p;
	}
}

//Ham kiem tra do uu tien cua toan tu
int getpriority(char op)
{
	if(op=='*' || op=='/' || op=='%')
		return 2;
	if(op=='+' || op=='-')
		return 1;
	return 0;
}


